<template>
  <div style="position: relative">
    <div class="content">
      <div class="content-a">
        <div class="content-a-1"></div>
        <div class="content-b">
          <div class="content-b-1"></div>
          <div class="content-c">
            <div class="content-1"></div>
            <div class="content-2">
              <div class="content-2-1"></div>
              <div class="content-3">
                <div class="content-4">
                  <div class="content-4-1"></div>
                  <div class="content-5">
                    <div class="content-5-2"></div>
                    <div class="content-5-1-1">
                      <div class="content-5-1"></div>
                      <div class="content-5-1-2">{{ numberValue }}</div>
                      <div class="content-5-btn content-5-btn1"></div>
                      <div class="content-5-btn content-5-btn2"></div>
                      <div class="content-5-btn content-5-btn3"></div>
                      <div class="content-5-btn content-5-btn4"></div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div id="lopp">
      <div
          class="ball"
          :class="[`status-${item.appRunState}`]"
          v-for="(item, index) in list"
          :key="item.id + index"
          @click="handelBall(item.id, index + 1)">
        <div class="img-dom">
          <div class="img-dom-1">
            <div class="app-name">{{ item.appName }}</div>
            <div class="app-sub">{{ item.appScene }}</div>
          </div>
          <div class="num-box">{{ item.pluginsNum }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {absolute} from "@antv/x6/lib/registry/port-layout/absolute";

export default {
  props: {
    list: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {
      numberValue: 1,
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.handleC();
    });
  },
  methods: {
    handleC() {
      var items = document.getElementsByClassName("ball");
      for (let i = 0; i < items.length; i++) {
        items[i].classList.add(`ball${i + 1}`);
      }
      for (let i = 0; i < items.length; i++) {
        items[i].addEventListener("mouseover", function () {
          for (let j = 0; j < items.length; j++) {
            items[j].style.animationPlayState = "paused";
          }
        });
        items[i].addEventListener("mouseout", function () {
          for (let j = 0; j < items.length; j++) {
            items[j].style.animationPlayState = "running";
          }
        });
      }
    },
    handelBall(id, data) {
      this.numberValue = data;
      this.$emit("handelBall", id);
    },
  },
};
</script>

<style lang="less" scoped>
  @a: 160px; // 椭圆x轴半径(长半径)
  @b: 80px; // 椭圆y轴半径(短半径)
  @s: 40; // 坐标点的数目(数目越大，动画越精细)

  @error: red;
  @blue: blue;
  @orange: #f7903d;
  @success: #2aef8a;
  @gray: gray;

  .ellips {
    width: @a*2;
    height: @b*2;
    border-radius: 100%;
    border: 1px solid #333;
    position: relative;
    margin: 30px 0 0 20px;
  }

  .dot {
    width: 20px;
    height: 20px;
    left: @a - 10px;
    top: @b - 10px;
    background: red;
    border-radius: 100%;
    position: absolute;
    animation: move 10s linear infinite;
  }

  .auto_custmot_btn {
    /* 动画时间 */
    animation-duration: 6s;
    /* 动画名称 */
    animation-name: shake;
    /* 规定动画的运动曲线 */
    animation-timing-function: ease;
    /* 规定在动画开始时延迟 */
    animation-delay: 1s;
    /* 动画播放次数 infinit无限循环*/
    animation-iteration-count: infinite;
    /* 规定动画是否轮流反向运动  normal reverse*/
    animation-direction: reverse;
  }

  .content {
    width: 350px;
    height: 350px;
    transform: rotate3d(65, -1, 1, 65deg);
    border-radius: 50%;
    margin: 20px auto;
    display: flex;
    justify-content: center;
    position: absolute;
    top: 45px;
    left: calc(50% - 175px);

    .content-a {
      width: 340px;
      height: 340px;
      border-radius: 50%;
      display: flex;
      position: absolute;
      justify-content: center;
      /*transform-style: preserve-3d;*/

      .content-a-1 {
        position: absolute;
        justify-content: center;
        background: url("~@/assets/img/indexHome/slices/gear.png") no-repeat;
        background-size: 100% 100%;
        animation: dom_rotate2 6s linear infinite;
        width: 340px;
        height: 340px;
      }

      .content-b {
        width: 325px;
        height: 325px;
        //   border: 1px solid #fff;
        border-radius: 50%;
        display: flex;
        position: absolute;
        justify-content: center;

        .content-b-1 {
          position: absolute;
          justify-content: center;
          background: url("~@/assets/img/indexHome/slices/ellipse-3.png") no-repeat;
          background-size: 100% 100%;
          animation: dom_rotate 6s linear infinite;
          width: 325px;
          height: 325px;
        }

        .content-c {
          width: 325px;
          height: 325px;
          //   border: 1px solid #fff;
          border-radius: 50%;
          display: flex;
          position: absolute;
          justify-content: center;

          .content-1 {
            position: absolute;
            background: url("~@/assets/img/indexHome/slices/blue-circle.png") no-repeat;
            background-size: 100% 100%;
            width: 310px;
            height: 310px;
          }

          .content-2 {
            width: 260px;
            height: 260px;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            background: url("~@/assets/img/indexHome/slices/non-luminous-layer.png") no-repeat;
            background-size: 100% 100%;

            .content-2-1 {
              position: absolute;
              background: url("~@/assets/img/indexHome/slices/luminous.png") no-repeat;
              background-size: 100% 100%;
              animation: dom_rotate 3s linear infinite;
              width: 260px;
              height: 260px;
            }

            .content-3 {
              width: 210px;
              height: 210px;
              border: 1px solid #409eff;
              border-radius: 50%;
              display: flex;
              justify-content: center;

              .content-4 {
                width: 170px;
                height: 170px;
                border-radius: 50%;
                display: flex;
                justify-content: center;
                // 白色半圆
                .content-4-1 {
                  position: absolute;
                  background: url("~@/assets/img/indexHome/slices/ellipse-3.png") no-repeat;
                  background-size: 100% 100%;
                  animation: dom_rotate1 3s linear infinite alternate;
                  transform: rotate(150deg);
                  width: 170px;
                  height: 170px;
                }

                // 蓝色虚线
                .content-5 {
                  width: 140px;
                  height: 140px;
                  border-radius: 50%;
                  display: flex;
                  justify-content: center;
                  position: absolute;

                  .content-5-2 {
                    width: 140px;
                    height: 140px;
                    border: 1px solid #ddd;
                    border-radius: 50%;
                    display: flex;
                    justify-content: center;
                    position: absolute;

                    // animation: run 10s steps(5, end) infinite;
                  }

                  .content-5-1-1 {
                    width: 140px;
                    height: 140px;
                    border-radius: 50%;
                    display: flex;
                    justify-content: center;
                    position: absolute;

                    .content-5-1 {
                      position: absolute;
                      background: url("~@/assets/img/indexHome/slices/ellipse-2.png") no-repeat;
                      background-size: 100% 100%;
                      animation: dom_rotate 9s linear infinite;
                      width: 120px;
                      height: 120px;
                    }

                    .content-5-1-2 {
                      width: 100%;
                      height: 100%;
                      position: absolute;
                      font-size: 88px;
                      top: 14px;
                      left: 0px;
                      color: #fff;
                      transform: rotate3d(55, 17, -3, -12deg);
                      z-index: 11;
                    }

                    .content-5-btn {
                      width: 10px;
                      height: 10px;
                      background: url('~@/assets/img/indexHome/slices/triangle.png') no-repeat 0 0;
                      background-size: 100% 100%;
                    }

                    .content-5-btn1 {
                      position: absolute;
                      top: 24px;
                      left: 34px;
                      transform: rotate(-150deg);
                      animation: fadenum_btn1 1s linear 0s infinite alternate;
                    }

                    .content-5-btn2 {
                      position: absolute;
                      top: 28px;
                      left: 104px;
                      transform: rotate(-51deg);
                      animation: fadenum_btn2 1s linear 0s infinite alternate;
                    }

                    .content-5-btn3 {
                      position: absolute;
                      top: 106px;
                      left: 36px;
                      transform: rotate(123deg);
                      animation: fadenum_btn3 1s linear 0s infinite alternate;
                    }

                    .content-5-btn4 {
                      position: absolute;
                      top: 104px;
                      left: 10px;
                      transform: rotate(35deg);
                      animation: fadenum_btn4 1s linear 0s infinite alternate;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  #lopp {
    width: 500px;
    height: 300px;
    // border: 2px solid #999;
    border-radius: 50%;
    position: absolute;
    left: calc(50% - 480px);
    top: 45px;

    .ball {
      width: 268px;
      height: 90px;
      cursor: pointer;
      position: absolute;
      color: #fff;
      font-size: 22px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: url("~@/assets/img/indexHome/slices/card-1.png") no-repeat;
      border-radius: 10px;
      padding: 15px;

      &.status-0 {
        background-color: @success;
      }

      &.status-1 {
        background-color: @blue;
      }

      &.status-2 {
        background-color: @error;
      }

      &.status-3 {
        background-color: @gray;
      }

      .img-dom {
        width: 100%;
        display: flex;
        align-items: center;
        height: 100%;

        .img-dom-1 {
          display: flex;
          flex: 1;
          flex-direction: column;
          justify-content: center;

          .app-name {
            margin-bottom: 10px;
          }

          .app-sub {
            font-size: 14px;
          }
        }

        .num-box {
          white-space: nowrap;
          width: 40px;
        }
      }
    }

    /* //7个圆,x和y轴动画加起来是20s , 20s/7 约等于 2.857s
          //每个球y轴动画延迟 从0递减2.857s,x轴与y相差动画时长的一半（10s/2） */

    .ball1 {
      animation: animX 10s cubic-bezier(0.36, 0, 0.64, 1) -5s infinite alternate,
      animY 10s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate,
      scale 20s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate;
    }

    .ball2 {
      animation: animX 10s cubic-bezier(0.36, 0, 0.64, 1) -9s infinite alternate,
      animY 10s cubic-bezier(0.36, 0, 0.64, 1) -4s infinite alternate,
      scale 20s cubic-bezier(0.36, 0, 0.64, 1) -4s infinite alternate;
    }

    .ball3 {
      animation: animX 10s cubic-bezier(0.36, 0, 0.64, 1) -13s infinite alternate,
      animY 10s cubic-bezier(0.36, 0, 0.64, 1) -8s infinite alternate,
      scale 20s cubic-bezier(0.36, 0, 0.64, 1) -8s infinite alternate;
    }

    .ball4 {
      animation: animX 10s cubic-bezier(0.36, 0, 0.64, 1) -17s infinite alternate,
      animY 10s cubic-bezier(0.36, 0, 0.64, 1) -12s infinite alternate,
      scale 20s cubic-bezier(0.36, 0, 0.64, 1) -12s infinite alternate;
    }

    .ball5 {
      animation: animX 10s cubic-bezier(0.36, 0, 0.64, 1) -21s infinite alternate,
      animY 10s cubic-bezier(0.36, 0, 0.64, 1) -16s infinite alternate,
      scale 20s cubic-bezier(0.36, 0, 0.64, 1) -16s infinite alternate;
    }
  }

  /* 中间三角形动画 */
  @keyframes fadenum_btn1 {
    0% {
      top: 24px;
      left: 34px;
    }

    100% {
      top: 34px;
      left: 44px;
    }
  }

  @keyframes fadenum_btn2 {
    0% {
      top: 28px;
      left: 104px;
    }

    100% {
      top: 38px;
      left: 94px;
    }
  }

  @keyframes fadenum_btn3 {
    0% {
      top: 106px;
      left: 36px;
    }

    100% {
      top: 96px;
      left: 46px;
    }
  }

  @keyframes fadenum_btn4 {
    0% {
      top: 104px;
      left: 100px;
    }

    100% {
      top: 94px;
      left: 90px;
    }
  }

  /* 圆环围绕运动 */
  @keyframes animX {
    0% {
      left: 0px;
    }

    100% {
      left: 700px;
    }
  }

  @keyframes animY {
    0% {
      top: 0px;
    }

    100% {
      top: 300px;
    }
  }

  @keyframes scale {
    0% {
      transform: scale(0.7);
    }

    50% {
      transform: scale(1);
    }

    100% {
      transform: scale(0.7);
    }
  }

  // 自转
  @keyframes dom_rotate {
    0% {
      transform: rotate(0deg);
    }

    100% {
      transform: rotate(360deg);
    }
  }

  @keyframes dom_rotate1 {
    0% {
      transform: rotate(140deg);
    }

    100% {
      transform: rotate(200deg);
    }
  }

  @keyframes dom_rotate2 {
    0% {
      transform: rotate(360deg);
    }

    100% {
      transform: rotate(0deg);
    }
  }

  @keyframes dom_rotate3 {
    0% {
      transform: rotate(0deg);
    }
    25% {
      transform: rotate(90deg);
    }
    50% {
      transform: rotate(180deg);
    }
    75% {
      transform: rotate(240deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }

  @keyframes run {
    from {
      transform: rotateZ(0);
    }

    to {
      transform: rotateZ(360deg);
    }
  }
</style>
